home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / teco.arc / APPEND.C < prev    next >
C/C++ Source or Header  |  1986-07-15  |  604b  |  32 lines

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. append() /* Append next page into buffer */
  5. {
  6. #include "teco.h"
  7.  
  8.     char c;
  9.     int croak=(bufsiz/3)*2;
  10.  
  11.     memset(&buffer[bufptr+1],'\0',bufsiz-bufptr);
  12.  
  13.     while (1) {
  14.         c=getc(in);
  15.         if (feof(in)) return;
  16.         if (ferror(in)) {
  17.             fprintf(stderr,"?INP, Input error\n\7");
  18.             clearerr(in);
  19.             return;
  20.         }
  21.         buffer[++bufptr]=c;
  22.         c=toascii(c);
  23.         if (c == 12) return;
  24.         if (c == 13 & bufptr > croak) {
  25.             buffer[++bufptr]=getc(in);
  26.             c=toascii(buffer[bufptr]);
  27.             if (c != 10) ungetc(buffer[bufptr--],in);
  28.             return;
  29.         }
  30.     }
  31. }
  32.